package com.boruishangge.home.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.alibaba.android.arouter.launcher.ARouter;
import com.boruishangge.common.APlusARoute;
import com.boruishangge.home.R;
import com.boruishangge.home.adapter.ListAdapter;
import com.boruishangge.home.databinding.FragmentListViewBinding;
import com.boruishangge.persagysdk.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

public class HomeListFragment extends BaseFragment implements  ListAdapter.onChoseNineClick {


    private FragmentListViewBinding binding;
    private ListAdapter listAdapter;
    View rootView;
    private List<String> list=new ArrayList<>();
    private  String name;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (rootView==null){
            rootView = inflater.inflate(R.layout.fragment_list_view, container, false);
            binding = DataBindingUtil.bind(rootView);
            initView();
            initData();
            initListener();
        }
        return rootView;
    }


    private  void  initView(){
     name= getArguments().getString("name");
    }

    private  void  initData(){





        for (int i=0;i<100;i++){
            if ("全部".equals(name)){
                list.add("全部"+i);
            }else   if ("大厅".equals(name)){
                list.add("大厅"+i);
            }else   if ("吧台".equals(name)){
                list.add("吧台"+i);
            }else   if ("包厢".equals(name)){
                list.add("包厢"+i);
            }else   if ("FOOD".equals(name)){
                list.add("FOOD"+i);
            }else   if ("DRINK".equals(name)){
                list.add("DRINK"+i);
            }else   if ("套餐".equals(name)){
                list.add("套餐"+i);
            }else   if ("店员点餐".equals(name)){
                list.add("店员点餐"+i);
            }
        }

        listAdapter=new ListAdapter(list,getActivity());
        listAdapter.setOnChoseNineClick(this);
        binding.rvView.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.rvView.setAdapter(listAdapter);
        listAdapter.notifyDataSetChanged();
    }

    @Override
    public void onChoseNineClick(String value) {
        ARouter.getInstance().build(APlusARoute.aplus_table_activty).withString("name",value).navigation();
    }
    private  void  initListener(){

    }
}
